﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_TimThanhPham : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CboHang")]
        private ComboBox _CboHang;
        [AccessedThroughProperty("CboKho")]
        private ComboBox _CboKho;
        [AccessedThroughProperty("CboNganhHang")]
        private ComboBox _CboNganhHang;
        [AccessedThroughProperty("CboNhomHangHoa")]
        private ComboBox _CboNhomHangHoa;
        [AccessedThroughProperty("CboXuatXu")]
        private ComboBox _CboXuatXu;
        [AccessedThroughProperty("CkXemHangTon")]
        private CheckBox _CkXemHangTon;
        [AccessedThroughProperty("CmdAddNew")]
        private Button _CmdAddNew;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("CmdRefesh")]
        private Button _CmdRefesh;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label12")]
        private Label _Label12;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label24")]
        private Label _Label24;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("Panel2")]
        private Panel _Panel2;
        [AccessedThroughProperty("TextBox1")]
        private TextBox _TextBox1;
        [AccessedThroughProperty("TxtCode")]
        private TextBox _TxtCode;
        [AccessedThroughProperty("TxtName")]
        private TextBox _TxtName;
        [AccessedThroughProperty("VSlist")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSlist;
        private IContainer components;
        private string mKhoaKho;
        private string mKhoaLoaiGia;
        private string mMaHang;
        private string mValueReturn;
        private DataView pData;
        private bool pLoad;
        public string strConditions;
        ComponentResourceManager manager;

        public Frm_TimThanhPham()
        {
            base.Activated += new EventHandler(this.Frm_TimHangHoa_Activated);
            base.Load += new EventHandler(this.Frm_TimHangHoa_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.mValueReturn = "";
            this.mMaHang = "";
            this.mKhoaKho = "";
            this.mKhoaLoaiGia = "";
            this.InitializeComponent();
        }

        private void CboHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.pLoad)
            {
                this.loadData();
            }
        }

        private void CboNganhHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.pLoad)
            {
                if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboNganhHang.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() != "")
                {
                    BuildComboModule.BuildCombo(this.CboNhomHangHoa, modGeneral.ListDanhMuc.NhomHangHoa, true, Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(" KhoaNganh = '", this.CboNganhHang.SelectedValue), "'")), "");
                }
                else
                {
                    BuildComboModule.BuildCombo(this.CboNhomHangHoa, modGeneral.ListDanhMuc.NhomHangHoa, true, "", "");
                }
            }
        }

        private void CboNhomHangHoa_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.pLoad)
            {
                this.loadData();
            }
        }

        private void CboXuatXu_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.pLoad)
            {
                this.loadData();
            }
        }

        private void CkXemHangTon_CheckedChanged(object sender, EventArgs e)
        {
            if (this.CkXemHangTon.Checked)
            {
                this.CboKho.Enabled = true;
            }
            else
            {
                this.CboKho.Enabled = false;
            }
        }

        private void CmdAddNew_Click(object sender, EventArgs e)
        {
            this.mValueReturn = "";
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            MyProject.Forms.Frm_HangHoa.objFrmCall = this;
            MyProject.Forms.Frm_HangHoa.cFrmTask = "I";
            MyProject.Forms.Frm_HangHoa.ShowDialog();
            if (this.mValueReturn.Trim() != "")
            {
                this.Close();
            }
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.ValueReturn = "";
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            this.pLoad = false;
            this.Close();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            string returnValue = "";
            if (this.VSlist.Rows.Count > 1)
            {
                //TODO: Review all rows to get the Ma(s).
                for (int i = 0; i < this.VSlist.Rows.Count;i++)
                {
                    if (this.VSlist[i, 0].ToString().Trim() != "")
                    {
                        returnValue += this.VSlist[i, 1].ToString().Trim() + "|" + this.VSlist[i, 2].ToString().Trim();
                        returnValue += ";";
                    }
                }

                this.mValueReturn = returnValue.Substring(0, returnValue.Length - 1);
            } 
            this.pLoad = false;
            this.Close();
        }

        private void CmdRefesh_Click(object sender, EventArgs e)
        {
            this.loadData();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_TimHangHoa_Activated(object sender, EventArgs e)
        {
            this.TxtCode.Focus();
        }

        private void Frm_TimHangHoa_Load(object sender, EventArgs e)
        {
            if (this.mKhoaLoaiGia == "")
            {
                this.mKhoaLoaiGia = modGeneral.H_GIACHUAN;
            }
            BuildComboModule.BuildCombo(this.CboNganhHang, modGeneral.ListDanhMuc.NganhHang, true, "", "");
            BuildComboModule.BuildCombo(this.CboNhomHangHoa, modGeneral.ListDanhMuc.NhomHangHoa, true, "", "");
            BuildComboModule.BuildCombo(this.CboHang, modGeneral.ListDanhMuc.HangSanXuat, true, "", "");
            BuildComboModule.BuildCombo(this.CboXuatXu, modGeneral.ListDanhMuc.QuocGia, true, "", "");
            BuildComboModule.BuildCombo(this.CboKho, modGeneral.ListDanhMuc.KhoHang, false, "", "");
            if (this.mKhoaKho.Trim() == "")
            {
                this.mKhoaKho = modGeneral.H_STOCKID;
            }
            this.CboKho.SelectedValue = this.mKhoaKho.Trim();
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboKho.SelectedValue), "", modGeneral.TypeOfValue.Nothing).ToString().Trim() != "")
            {
                this.CkXemHangTon.Checked = true;
            }
            this.pLoad = true;
            if (this.pData == null)
            {
                this.loadData();
            }
            this.TxtCode.Text = this.mMaHang;
            this.TxtCode.SelectionStart = Strings.Len(this.TxtCode.Text.Trim());

            SetEvents();
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Frm_TimThanhPham));
            this._VSlist = new C1.Win.C1FlexGrid.C1FlexGrid();
            this._Panel2 = new System.Windows.Forms.Panel();
            this._CmdRefesh = new System.Windows.Forms.Button();
            this._TextBox1 = new System.Windows.Forms.TextBox();
            this._CmdAddNew = new System.Windows.Forms.Button();
            this._CmdCancel = new System.Windows.Forms.Button();
            this._CmdOK = new System.Windows.Forms.Button();
            this._TxtName = new System.Windows.Forms.TextBox();
            this._TxtCode = new System.Windows.Forms.TextBox();
            this._Panel1 = new System.Windows.Forms.Panel();
            this._CboKho = new System.Windows.Forms.ComboBox();
            this._CkXemHangTon = new System.Windows.Forms.CheckBox();
            this._Label2 = new System.Windows.Forms.Label();
            this._CboNganhHang = new System.Windows.Forms.ComboBox();
            this._Label24 = new System.Windows.Forms.Label();
            this._CboXuatXu = new System.Windows.Forms.ComboBox();
            this._Label12 = new System.Windows.Forms.Label();
            this._CboHang = new System.Windows.Forms.ComboBox();
            this._Label1 = new System.Windows.Forms.Label();
            this._CboNhomHangHoa = new System.Windows.Forms.ComboBox();
            ((System.ComponentModel.ISupportInitialize)(this._VSlist)).BeginInit();
            this._Panel2.SuspendLayout();
            this._Panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // _VSlist
            // 
            this._VSlist.AllowEditing = false;
            this._VSlist.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.XpThemes;
            this._VSlist.ColumnInfo = resources.GetString("_VSlist.ColumnInfo");
            this._VSlist.Dock = System.Windows.Forms.DockStyle.Fill;
            this._VSlist.ExtendLastCol = true;
            this._VSlist.FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.None;
            this._VSlist.Location = new System.Drawing.Point(0, 45);
            this._VSlist.Name = "_VSlist";
            this._VSlist.Rows.Count = 1;
            this._VSlist.Rows.DefaultSize = 17;
            this._VSlist.SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Row;
            this._VSlist.Size = new System.Drawing.Size(784, 416);
            this._VSlist.StyleInfo = resources.GetString("_VSlist.StyleInfo");
            this._VSlist.TabIndex = 7;
            this._VSlist.VisualStyle = C1.Win.C1FlexGrid.VisualStyle.Office2007Blue;
            // 
            // _Panel2
            // 
            this._Panel2.Controls.Add(this._CmdRefesh);
            this._Panel2.Controls.Add(this._TextBox1);
            this._Panel2.Controls.Add(this._CmdAddNew);
            this._Panel2.Controls.Add(this._CmdCancel);
            this._Panel2.Controls.Add(this._CmdOK);
            this._Panel2.Controls.Add(this._TxtName);
            this._Panel2.Controls.Add(this._TxtCode);
            this._Panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
            this._Panel2.Location = new System.Drawing.Point(0, 461);
            this._Panel2.Name = "_Panel2";
            this._Panel2.Padding = new System.Windows.Forms.Padding(2);
            this._Panel2.Size = new System.Drawing.Size(784, 52);
            this._Panel2.TabIndex = 8;
            // 
            // _CmdRefesh
            // 
            this._CmdRefesh.Image = ((System.Drawing.Image)(resources.GetObject("_CmdRefesh.Image")));
            this._CmdRefesh.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._CmdRefesh.Location = new System.Drawing.Point(96, 25);
            this._CmdRefesh.Name = "_CmdRefesh";
            this._CmdRefesh.Size = new System.Drawing.Size(87, 24);
            this._CmdRefesh.TabIndex = 7;
            this._CmdRefesh.Text = "&Refesh";
            this._CmdRefesh.UseVisualStyleBackColor = true;
            // 
            // _TextBox1
            // 
            this._TextBox1.Location = new System.Drawing.Point(106, 2);
            this._TextBox1.Name = "_TextBox1";
            this._TextBox1.Size = new System.Drawing.Size(100, 20);
            this._TextBox1.TabIndex = 6;
            // 
            // _CmdAddNew
            // 
            this._CmdAddNew.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._CmdAddNew.Location = new System.Drawing.Point(3, 25);
            this._CmdAddNew.Name = "_CmdAddNew";
            this._CmdAddNew.Size = new System.Drawing.Size(87, 24);
            this._CmdAddNew.TabIndex = 5;
            this._CmdAddNew.Text = "&Thêm mới";
            this._CmdAddNew.UseVisualStyleBackColor = true;
            // 
            // _CmdCancel
            // 
            this._CmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this._CmdCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._CmdCancel.Location = new System.Drawing.Point(706, 24);
            this._CmdCancel.Name = "_CmdCancel";
            this._CmdCancel.Size = new System.Drawing.Size(73, 24);
            this._CmdCancel.TabIndex = 4;
            this._CmdCancel.Text = "Th&oát";
            this._CmdCancel.UseVisualStyleBackColor = true;
            // 
            // _CmdOK
            // 
            this._CmdOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this._CmdOK.Location = new System.Drawing.Point(624, 24);
            this._CmdOK.Name = "_CmdOK";
            this._CmdOK.Size = new System.Drawing.Size(77, 24);
            this._CmdOK.TabIndex = 3;
            this._CmdOK.Text = "&Chọn";
            this._CmdOK.UseVisualStyleBackColor = true;
            // 
            // _TxtName
            // 
            this._TxtName.Location = new System.Drawing.Point(210, 2);
            this._TxtName.Name = "_TxtName";
            this._TxtName.Size = new System.Drawing.Size(305, 20);
            this._TxtName.TabIndex = 1;
            // 
            // _TxtCode
            // 
            this._TxtCode.Location = new System.Drawing.Point(2, 2);
            this._TxtCode.Name = "_TxtCode";
            this._TxtCode.Size = new System.Drawing.Size(100, 20);
            this._TxtCode.TabIndex = 0;
            // 
            // _Panel1
            // 
            this._Panel1.Controls.Add(this._CboKho);
            this._Panel1.Controls.Add(this._CkXemHangTon);
            this._Panel1.Controls.Add(this._Label2);
            this._Panel1.Controls.Add(this._CboNganhHang);
            this._Panel1.Controls.Add(this._Label24);
            this._Panel1.Controls.Add(this._CboXuatXu);
            this._Panel1.Controls.Add(this._Label12);
            this._Panel1.Controls.Add(this._CboHang);
            this._Panel1.Controls.Add(this._Label1);
            this._Panel1.Controls.Add(this._CboNhomHangHoa);
            this._Panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this._Panel1.Location = new System.Drawing.Point(0, 0);
            this._Panel1.Name = "_Panel1";
            this._Panel1.Size = new System.Drawing.Size(784, 45);
            this._Panel1.TabIndex = 6;
            // 
            // _CboKho
            // 
            this._CboKho.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CboKho.FormattingEnabled = true;
            this._CboKho.Location = new System.Drawing.Point(665, 19);
            this._CboKho.Name = "_CboKho";
            this._CboKho.Size = new System.Drawing.Size(117, 21);
            this._CboKho.TabIndex = 60;
            // 
            // _CkXemHangTon
            // 
            this._CkXemHangTon.AutoSize = true;
            this._CkXemHangTon.BackColor = System.Drawing.Color.Transparent;
            this._CkXemHangTon.ForeColor = System.Drawing.Color.Black;
            this._CkXemHangTon.Location = new System.Drawing.Point(664, 2);
            this._CkXemHangTon.Name = "_CkXemHangTon";
            this._CkXemHangTon.Size = new System.Drawing.Size(92, 17);
            this._CkXemHangTon.TabIndex = 59;
            this._CkXemHangTon.Text = "Xem hàng tồn";
            this._CkXemHangTon.UseVisualStyleBackColor = false;
            // 
            // _Label2
            // 
            this._Label2.AutoSize = true;
            this._Label2.BackColor = System.Drawing.Color.Transparent;
            this._Label2.ForeColor = System.Drawing.Color.Black;
            this._Label2.Location = new System.Drawing.Point(2, 4);
            this._Label2.Name = "_Label2";
            this._Label2.Size = new System.Drawing.Size(66, 13);
            this._Label2.TabIndex = 58;
            this._Label2.Text = "Ngành hàng";
            // 
            // _CboNganhHang
            // 
            this._CboNganhHang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CboNganhHang.FormattingEnabled = true;
            this._CboNganhHang.Location = new System.Drawing.Point(5, 19);
            this._CboNganhHang.Name = "_CboNganhHang";
            this._CboNganhHang.Size = new System.Drawing.Size(179, 21);
            this._CboNganhHang.TabIndex = 57;
            // 
            // _Label24
            // 
            this._Label24.AutoSize = true;
            this._Label24.BackColor = System.Drawing.Color.Transparent;
            this._Label24.ForeColor = System.Drawing.Color.Black;
            this._Label24.Location = new System.Drawing.Point(370, 4);
            this._Label24.Name = "_Label24";
            this._Label24.Size = new System.Drawing.Size(43, 13);
            this._Label24.TabIndex = 56;
            this._Label24.Text = "Xuất xứ";
            // 
            // _CboXuatXu
            // 
            this._CboXuatXu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CboXuatXu.FormattingEnabled = true;
            this._CboXuatXu.Location = new System.Drawing.Point(369, 19);
            this._CboXuatXu.Name = "_CboXuatXu";
            this._CboXuatXu.Size = new System.Drawing.Size(131, 21);
            this._CboXuatXu.TabIndex = 55;
            // 
            // _Label12
            // 
            this._Label12.AutoSize = true;
            this._Label12.BackColor = System.Drawing.Color.Transparent;
            this._Label12.ForeColor = System.Drawing.Color.Black;
            this._Label12.Location = new System.Drawing.Point(500, 3);
            this._Label12.Name = "_Label12";
            this._Label12.Size = new System.Drawing.Size(76, 13);
            this._Label12.TabIndex = 54;
            this._Label12.Text = "Hãng sản xuất";
            // 
            // _CboHang
            // 
            this._CboHang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CboHang.FormattingEnabled = true;
            this._CboHang.Location = new System.Drawing.Point(503, 19);
            this._CboHang.Name = "_CboHang";
            this._CboHang.Size = new System.Drawing.Size(157, 21);
            this._CboHang.TabIndex = 53;
            // 
            // _Label1
            // 
            this._Label1.AutoSize = true;
            this._Label1.BackColor = System.Drawing.Color.Transparent;
            this._Label1.ForeColor = System.Drawing.Color.Black;
            this._Label1.Location = new System.Drawing.Point(187, 4);
            this._Label1.Name = "_Label1";
            this._Label1.Size = new System.Drawing.Size(83, 13);
            this._Label1.TabIndex = 1;
            this._Label1.Text = "Nhóm hàng hóa";
            // 
            // _CboNhomHangHoa
            // 
            this._CboNhomHangHoa.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this._CboNhomHangHoa.FormattingEnabled = true;
            this._CboNhomHangHoa.Location = new System.Drawing.Point(189, 19);
            this._CboNhomHangHoa.Name = "_CboNhomHangHoa";
            this._CboNhomHangHoa.Size = new System.Drawing.Size(175, 21);
            this._CboNhomHangHoa.TabIndex = 2;
            // 
            // Frm_TimThanhPham
            // 
            this.CancelButton = this._CmdCancel;
            this.ClientSize = new System.Drawing.Size(784, 513);
            this.ControlBox = false;
            this.Controls.Add(this._VSlist);
            this.Controls.Add(this._Panel2);
            this.Controls.Add(this._Panel1);
            this.Name = "Frm_TimThanhPham";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "TIM THANH PHAM";
            ((System.ComponentModel.ISupportInitialize)(this._VSlist)).EndInit();
            this._Panel2.ResumeLayout(false);
            this._Panel2.PerformLayout();
            this._Panel1.ResumeLayout(false);
            this._Panel1.PerformLayout();
            this.ResumeLayout(false);

        }

        public void InsertHangHoa(string pKhoa, string pMa, string pTen)
        {
            this.ValueReturn = pKhoa + "|" + pMa + "|" + pTen;
        }

        public void loadData()
        {
            clsDMHangHoa hoa = new clsDMHangHoa();
            string strConditions = "";
            strConditions = " 1 = 1 ";
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboNganhHang.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() != "")
            {
                strConditions = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(strConditions + " And HH.KhoaNganh = '", this.CboNganhHang.SelectedValue), "'"));
            }
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboNhomHangHoa.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() != "")
            {
                strConditions = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(strConditions + " And HH.KhoaNhom = '", this.CboNhomHangHoa.SelectedValue), "'"));
            }
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboHang.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() != "")
            {
                strConditions = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(strConditions + " And HH.KhoaHangSanXuat = '", this.CboHang.SelectedValue), "'"));
            }
            if (LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboXuatXu.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim() != "")
            {
                strConditions = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(strConditions + " And HH.KhoaQuocGia = '", this.CboXuatXu.SelectedValue), "'"));
            }
            if (LVYModule.ReturnIfNull(this.strConditions, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() != "")
            {
                strConditions = strConditions + this.strConditions;
            }
            //this.pData = new DataView(hoa.GetListSearch("", strConditions, LVYModule.ReturnIfNull(RuntimeHelpers.GetObjectValue(this.CboKho.SelectedValue), "", modGeneral.TypeOfValue.String).ToString().Trim(), ""));
            //this.VSlist.DataSource = this.pData;
            ////this.VSlist.Cols[0].Visible = false;
            //this.VSlist.Cols[2].Width = 100;
            //this.VSlist.Cols[3].Width = 100;
            //this.VSlist.Cols[4].Width = 300;
            //this.VSlist.Cols[5].Width = 80;
            //this.VSlist.Cols[6].Width = 100;
            ////this.VSlist.Cols[7].Width = 60;
            //this.VSlist[0, 2] = modGeneral.Tranlated("M\x00e3 h\x00e0ng h\x00f3a", "");
            //this.VSlist[0, 3] = modGeneral.Tranlated("M\x00e3 vạch", "");
            //this.VSlist[0, 4] = modGeneral.Tranlated("T\x00ean h\x00e0ng h\x00f3a", "");
            //this.VSlist[0, 5] = modGeneral.Tranlated("ĐVT", "");
            //this.VSlist[0, 6] = modGeneral.Tranlated("Gi\x00e1 b\x00e1n", "");
            ////this.VSlist[0, 7] = modGeneral.Tranlated("SL tồn", "");
            //this.VSlist.Cols[6].DataType = System.Type.GetType("System.Decimal");
            //this.VSlist.Cols[6].Format = modGeneral.H_FORMATNUMBER + ".00";
            ////this.VSlist.Cols[7].DataType = System.Type.GetType("System.Decimal");
            ////this.VSlist.Cols[7].Format = modGeneral.H_FORMATNUMBER + ".00";
      
            DataTable detailsPA = hoa.GetListThanhPham();
            //this.VSlist.Rows.Count = 1;
            this.VSlist.DataSource = detailsPA;
            //if (detailsPA != null)
            //{
            //    C1.Win.C1FlexGrid.C1FlexGrid vSlist = this.VSlist;
            //    int num2 = detailsPA.Rows.Count - 1;
            //    for (int i = 0; i <= num2; i++)
            //    {
            //        vSlist.AddItem("");
            //        vSlist[vSlist.Rows.Count - 1, 0] = RuntimeHelpers.GetObjectValue(detailsPA.Rows[i]["Khoa"]);
            //        vSlist[vSlist.Rows.Count - 1, 1] = RuntimeHelpers.GetObjectValue(detailsPA.Rows[i]["Chon"]); ;
            //        vSlist[vSlist.Rows.Count - 1, 2] = RuntimeHelpers.GetObjectValue(detailsPA.Rows[i]["Ma"]);
            //        vSlist[vSlist.Rows.Count - 1, 3] = RuntimeHelpers.GetObjectValue(detailsPA.Rows[i]["TenHangHoa"]);                  
            //    }
            //    vSlist = null;                
            //}
        }

        public void Search(string strCode, string strName)
        {
            string left = "";
            if (strCode.Trim() != "")
            {
                left = "Ma LIKE '" + strCode + "%'";
            }
            if (strName.Trim() != "")
            {
                left = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(left, Interaction.IIf(left.Trim() != "", " And Ten LIKE '%" + strName + "%'", " Ten LIKE '%" + strName + "%'")));
            }
            //this.pData.RowFilter = left;
            //this.VSlist.Cols[2].Width = 100;
            //this.VSlist.Cols[3].Width = 100;
            //this.VSlist.Cols[4].Width = 300;
            //this.VSlist.Cols[5].Width = 80;
            if (this.VSlist.Rows.Count != 1)
            {
                this.VSlist.Select(1, 0, 1, this.VSlist.Cols.Count - 1);
            }
        }

        public void SearchBarCode(string strBarCode)
        {
            string str = "";
            str = "MaVach LIKE '" + strBarCode + "%'";
            this.pData.RowFilter = str;
            //this.VSlist.Cols[2].Width = 100;
            //this.VSlist.Cols[3].Width = 100;
            //this.VSlist.Cols[4].Width = 300;
            //this.VSlist.Cols[5].Width = 80;
            if (this.VSlist.Rows.Count != 1)
            {
                this.VSlist.Select(1, 0, 1, this.VSlist.Cols.Count - 1);
            }
        }

        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            this.SearchBarCode(this.TextBox1.Text.Trim());
        }

        private void TxtCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
            if (e.KeyCode == Keys.Down)
            {
                if (this.VSlist.Row < (this.VSlist.Rows.Count - 1))
                {
                    this.VSlist.Select(this.VSlist.Row + 1, 1);
                }
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                if (this.VSlist.Row > 1)
                {
                    this.VSlist.Select(this.VSlist.Row - 1, 1);
                }
                e.SuppressKeyPress = true;
            }
        }

        private void TxtCode_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtCode.Text, "");
        }

        private void TxtName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
            if (e.KeyCode == Keys.Down)
            {
                if (this.VSlist.Row < (this.VSlist.Rows.Count - 1))
                {
                    this.VSlist.Select(this.VSlist.Row + 1, 1);
                }
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                if (this.VSlist.Row > 1)
                {
                    this.VSlist.Select(this.VSlist.Row - 1, 1);
                }
                e.SuppressKeyPress = true;
            }
        }

        private void TxtName_TextChanged(object sender, EventArgs e)
        {
            this.Search("", this.TxtName.Text);
        }

        private void VSlist_DoubleClick(object sender, EventArgs e)
        {
            this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
        }

        public void SetEvents()
        {
            this._CboHang.SelectedIndexChanged += this.CboHang_SelectedIndexChanged;
            this._CboNganhHang.SelectedIndexChanged += this.CboNganhHang_SelectedIndexChanged;
            this._CboNhomHangHoa.SelectedIndexChanged += this.CboNhomHangHoa_SelectedIndexChanged;
            this._CboXuatXu.SelectedIndexChanged += this.CboXuatXu_SelectedIndexChanged;
            this._CkXemHangTon.CheckedChanged += this.CkXemHangTon_CheckedChanged;
            this._CmdAddNew.Click += this.CmdAddNew_Click;
            this._CmdCancel.Click += this.CmdCancel_Click;
            this._CmdOK.Click += this.CmdOK_Click;
            this._CmdRefesh.Click += this.CmdRefesh_Click;
            this._TextBox1.TextChanged += this.TextBox1_TextChanged;
            this._TxtCode.TextChanged += this.TxtCode_TextChanged;
            this._TxtCode.KeyDown += this.TxtCode_KeyDown;
            this._TxtName.TextChanged += this.TxtName_TextChanged;
            this._TxtName.KeyDown += this.TxtName_KeyDown;
            this._VSlist.DoubleClick += this.VSlist_DoubleClick;
        }

        internal virtual ComboBox CboHang
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboHang;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboHang_SelectedIndexChanged);
                if (this._CboHang != null)
                {
                    this._CboHang.SelectedIndexChanged -= handler;
                }
                this._CboHang = value;
                if (this._CboHang != null)
                {
                    this._CboHang.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboKho
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboKho;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboKho = value;
            }
        }

        internal virtual ComboBox CboNganhHang
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboNganhHang;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboNganhHang_SelectedIndexChanged);
                if (this._CboNganhHang != null)
                {
                    this._CboNganhHang.SelectedIndexChanged -= handler;
                }
                this._CboNganhHang = value;
                if (this._CboNganhHang != null)
                {
                    this._CboNganhHang.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboNhomHangHoa
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboNhomHangHoa;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboNhomHangHoa_SelectedIndexChanged);
                if (this._CboNhomHangHoa != null)
                {
                    this._CboNhomHangHoa.SelectedIndexChanged -= handler;
                }
                this._CboNhomHangHoa = value;
                if (this._CboNhomHangHoa != null)
                {
                    this._CboNhomHangHoa.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboXuatXu
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboXuatXu;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboXuatXu_SelectedIndexChanged);
                if (this._CboXuatXu != null)
                {
                    this._CboXuatXu.SelectedIndexChanged -= handler;
                }
                this._CboXuatXu = value;
                if (this._CboXuatXu != null)
                {
                    this._CboXuatXu.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual CheckBox CkXemHangTon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CkXemHangTon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CkXemHangTon_CheckedChanged);
                if (this._CkXemHangTon != null)
                {
                    this._CkXemHangTon.CheckedChanged -= handler;
                }
                this._CkXemHangTon = value;
                if (this._CkXemHangTon != null)
                {
                    this._CkXemHangTon.CheckedChanged += handler;
                }
            }
        }

        internal virtual Button CmdAddNew
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdAddNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdAddNew_Click);
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click -= handler;
                }
                this._CmdAddNew = value;
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click += handler;
                }
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual Button CmdRefesh
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdRefesh;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdRefesh_Click);
                if (this._CmdRefesh != null)
                {
                    this._CmdRefesh.Click -= handler;
                }
                this._CmdRefesh = value;
                if (this._CmdRefesh != null)
                {
                    this._CmdRefesh.Click += handler;
                }
            }
        }

        public string KhoaKho
        {
            get
            {
                return this.mKhoaKho;
            }
            set
            {
                this.mKhoaKho = value;
            }
        }

        public string KhoaLoaiGia
        {
            get
            {
                return this.mKhoaLoaiGia;
            }
            set
            {
                this.mKhoaLoaiGia = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label12
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label12;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label12 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label24
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label24;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label24 = value;
            }
        }

        public string MaHang
        {
            get
            {
                return this.mMaHang;
            }
            set
            {
                this.mMaHang = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual Panel Panel2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel2 = value;
            }
        }

        internal virtual TextBox TextBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TextBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TextBox1_TextChanged);
                if (this._TextBox1 != null)
                {
                    this._TextBox1.TextChanged -= handler;
                }
                this._TextBox1 = value;
                if (this._TextBox1 != null)
                {
                    this._TextBox1.TextChanged += handler;
                }
            }
        }

        internal virtual TextBox TxtCode
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtCode;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtCode_TextChanged);
                KeyEventHandler handler2 = new KeyEventHandler(this.TxtCode_KeyDown);
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged -= handler;
                    this._TxtCode.KeyDown -= handler2;
                }
                this._TxtCode = value;
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged += handler;
                    this._TxtCode.KeyDown += handler2;
                }
            }
        }

        internal virtual TextBox TxtName
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtName;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtName_TextChanged);
                KeyEventHandler handler2 = new KeyEventHandler(this.TxtName_KeyDown);
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged -= handler;
                    this._TxtName.KeyDown -= handler2;
                }
                this._TxtName = value;
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged += handler;
                    this._TxtName.KeyDown += handler2;
                }
            }
        }

        public string ValueReturn
        {
            get
            {
                return this.mValueReturn;
            }
            set
            {
                this.mValueReturn = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSlist
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSlist;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.VSlist_DoubleClick);
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick -= handler;
                }
                this._VSlist = value;
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick += handler;
                }
            }
        }
    }
}

